package controllers

import (
	"fmt"
	"roles/models"
	"roles/services"

	beego "github.com/beego/beego/v2/server/web"
)

type RolesController struct {
	beego.Controller
}

// 权限校验
// @Title 获取晨报周报章节类型列表
// @Description 获取晨报周报章节类型列表
// @Param	StopType	query	string	true	"停更类型 stop; disable;"
// @Success 200 {object} models.ReportListResp
// @router /auth-check [get]
func (this *RolesController) AuthCheck() {
	br := new(models.BaseResponse).Init()
	defer func() {
		this.Data["json"] = br
		this.ServeJSON()
	}()
	id, _ := this.GetInt("role_id")

	svc := new(services.SysRoleService)

	ok, err := svc.CheckAuth(id)
	if err != nil || !ok {
		br.Ret = 403
		br.Msg = fmt.Errorf("权限校验失败 %w", err).Error()
	}
	br.Ret = 200
	br.Msg = "权限校验成功"
	br.Success = true
}
